<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="../css/newidex.css"/>
</head>
<body class="white">
	<div class="mui-content loading" id="vueMain">
	 	<div class="tops-name">
	 		<img :src="list.shop.logo" alt="" />
	 		<div class="name">{{list.shop.shop_name}}</div>
	 	</div>
	 	<div id="refreshContainer" class="mui-content mui-scroll-wrapper" style="top: 110px;">
		  <div class="mui-scroll" style="padding-top: 40px;">
		    	<div class="mui-row">
		    		<div v-if="list.goods.length==0">
		    			<p style="text-align: center;padding:50px 0">这个商家什么也没有!!</p>
		    		</div>
		    		<template v-else v-for="(item,index) in list.goods">
		    			<div class="items mui-col-xs-6 mui-col-sm-6 " :data-id="item.id">
		    				<img :src="item.img" alt="" />
		    				<p class="name">{{item.name}}</p>
		    				<p class="price" v-if="item.price!='0.00'">¥{{item.price}}</p>
		    				<p class="price" v-else>询价</p>
		    			</div>
		    		</template>
		    	</div>
		  </div>
		</div>
	</div>
	
	
	
<script src="../js/mui.min.js"></script>
<!--<script src="../js/mui.extend.js"></script>-->
<script src="../js/vue.min.js"></script>
<script src="../js/mui.pullToRefresh.js"></script>
<script src="../js/mui.pullToRefresh.material.js"></script>
<script src="../js/bexta.js"></script>
<script type="text/javascript">
	var apps, views, user;
	mui.init();
	mui.plusReady(function () {
		views = bexta.getWebview();
		user = bexta.getStorage(USER);
		bexta.setStatus(true)
//		bexta.toggleStatus(views);
		bexta.ajax(api.shop_infor, function(res){
			initVue(res);
		},{data:{sid:views.sid, uid:user&&user.uid, firstrow:0, listrow:10}});
	});
	function initVue(res){
		apps = new Vue({
			el:'#vueMain', 
			data:{
				first:res.goods.length, 
				last:10,
				list:res
			},
			mounted:function(){
				document.querySelector('.loading').classList.add('loadRun');
				window.onload = function(){
					var hh = document.querySelector('.tops-name').offsetHeight;
					document.querySelector('#refreshContainer').style.top = (hh + 20 + bexta.getStatusHeight()) + 'px';
				}
				var self = this;
//				mui.init({
//					beforeback:function(){
//						console.log( 'before' )
//						return true;	
//					},
//					  pullRefresh : {
//					    container:"#refreshContainer",
//					    up : {
//						      height:50,
//						      auto:false,
//						      contentrefresh : "正在加载...",
//						      contentnomore:'没有更多数据了',
//						      callback :function(){
//						      	var that = this;
//						      	bexta.ajax(api.shop_infor, function(res){
//						      		if( res.goods.length < self.last ){
//						      			that.endPullupToRefresh(true);
//						      		}else{
//						      			mui.each(res.goods, function(){
//						      				self.list.goods.push(this);
//						      			});
//						      			self.first = self.list.goods.length;
//						      			that.endPullupToRefresh(false);
//						      		}
//								},{data:{sid:views.sid, uid:user&&user.uid, firstrow:self.first, listrow:self.last}});
//						      }
//						    }
//					  }
//			});
			var deceleration = mui.os.ios?0.003:0.0009;
			mui('.mui-scroll-wrapper').scroll({
				bounce: true,
				indicators: true, //是否显示滚动条
				deceleration:deceleration
			});
			mui('#refreshContainer .mui-scroll').pullToRefresh({
				up:{
					callback:function(){
						var that = this;
						bexta.ajax(api.shop_infor, function(res){
				      		if( res.goods.length < self.last ){
				      			that.endPullUpToRefresh(true);
				      		}else{
				      			mui.each(res.goods, function(){
				      				self.list.goods.push(this);
				      			});
				      			self.first = self.list.goods.length;
				      			that.endPullUpToRefresh(false);
				      		}
						},{data:{sid:views.sid, uid:user&&user.uid, firstrow:self.first, listrow:self.last}});
						
					}
				}
			});
			
			mui('body').on('tap', '.items', function(){
				var id = this.getAttribute('data-id');
				plus.webview.getWebviewById('detail')&&plus.webview.getWebviewById('detail').close('none')
				plus.webview.getWebviewById('detail2')&&plus.webview.getWebviewById('detail2').close('none')
					mui.later(function(){
						mui.openWindow({
							id:'detail',
							url:'detail.html',
							extras:{
								pid:id
							},
//							createNew:views.opener().id=='detail'?true:(views.opener().id=='detail2'?true:false),    //暂时的处理方法 
							show:{autoShow:true,aniShow:'pop-in'},
							waiting:{autoShow:false}
						});
					}, 10);
			});
		}
		});
	}
</script>
</body>
</html>